<?php echo form_dropdown('cat_id', array('' => lang('global:all')) + $cat_select, $cat_id,'id="cat_id" class="chzn-select-deselect select-goto" style="width:30%" ');?>

<?php 
$attributes = array('class' => 'adminForm ', 'id' => '');
//$hidden = array('url' => $url);
echo form_open(site_url('admin/polls/answer/ordering'),$attributes);?>
<table class="kunTable">
	<thead>
    	<tr>
        	<th width="20">{{ helper:lang line="global:identifier" }}</th>
            <th width="70">{{ helper:lang line="global:sort" }}</th>
            <th>{{ helper:lang line="polls:answer" }}</th>
            <th>{{ helper:lang line="polls:votes" }}</th>
            <th width="50">{{ helper:lang line="global:action" }}</th>
        </tr>
    </thead>
    <tbody>
    	{{model}}
        <tr>
        	<td>{{ helper:count identifier }}</td>
            <td>
                	{{ button:href: tag="button" class="save sort" title={helper:lang line="global:save"} data-toggle="tooltip" }}
                 	<input pid="{{id}}" class="inputText medium ordering" type="text" value="{{ordering}}" />
            </td>
            <td>{{ title }}</td>
            <td>{{ votes }}</td>
            <td>
					{{button:href: class="edit" title={helper:lang line="global:edit"} data-toggle="tooltip" 
                    		href={url:site uri="admin/polls/answer/edit/{{id}}"} }}
                    {{button:href: class="del" title={ helper:lang line="global:delete"} data-toggle="tooltip" 
                    		href={url:site uri="admin/polls/answer/delete/{{id}}"} }}
			</td>
        </tr>
        {{/model}}
    </tbody>
</table>
<?php echo form_close() ?>

<script type="text/javascript">
$('select.select-goto').change(function(){
	$val = $(this).val();
	location.href='{{url:site uri="admin/polls/answer/'+$val+'"}}';
});
</script>

<script type="text/javascript">
$('.sort').click(function(){
	
	$obj = $(this).siblings('input.ordering');
	$id = $obj.attr('pid');
	$value = $obj.val();
	
	$.ajax({
		url:$('form.adminForm').attr('action'),
		data:{id:$id, ordering:$value},
		type:'post',
		success: function(){
			location.reload();
		}
	});
	return false;
});

$(window).load(function(){
	$('a.del').click(function(){
		if(kunkun.delete==true){
			$.ajax({
				url:$(this).attr('href'),
				success:function(){
					location.reload();
				}
			});
		}
		return false;
	});
});

</script>
